package org.example.controller;

import lombok.Data;

@Data
public class HttpResult<T> {
    private String msg;
    private boolean success;
    private T data;
    public static <T> HttpResult<T> success(T data){
        HttpResult<T> httpResult=new HttpResult<>();
        httpResult.data=data;
        httpResult.msg=null;
        httpResult.success=true;
        return httpResult;
    }
    public static HttpResult<Void> error(String msg){
        HttpResult<Void> httpResult=new HttpResult<>();
        httpResult.success=false;
        httpResult.msg=msg;
        return httpResult;
    }
    public static HttpResult<Void> internalError(){
        HttpResult<Void> httpResult=new HttpResult<>();
        httpResult.msg="内部错误";
        httpResult.success=false;
        return httpResult;
    }
}
